import { defineStore } from "pinia";
export const usePayStore = defineStore("goPay", {
    state: () => {
      return {
        orderData:JSON.parse(localStorage.getItem('usergoPay'))  || [
        //     {
        //     uId:'',
        //     userName:'',
        //     userPhone:'',
        //     goods_name:'',
        //     goods_price:0,
        //     goods_id:'',
        //     goods_num:'',
        //     order_id:'',
        //     order_time:'',
        //     order_address:'',
        //     order_remarks:'',
        //     order_delivery:6,
        //     order_total_price:'',
        //     use_wallet:false,
        //     goods_coffee_wallet:''
        //     is_sex:''
        // }
    ]
      };
    },
    actions:{
        edit(payload){
            // 存放数据 this.orderData
            // ...  
        },
        editPayList(payload){
          this.orderData = []
          let msgObj = {}
          payload.forEach((item,index) =>{
            msgObj = {}
            msgObj.goods_name = item.goods
            msgObj.goods_num = item.goods_num
            msgObj.goods_price = item.goods_price
            msgObj.goods_id = item.proId
            this.orderData.push(msgObj)
          })
        },
        editaddress(payload) {
          this.orderData.forEach(item => {
              item.userName = payload.userName
              item.userPhone = payload.userPhone
              item.order_address = payload.address + payload.addressDetail
              item.is_sex = payload.is_sex          
          })
          localStorage.setItem('usergoPay',JSON.stringify(this.orderData))
        }
    }
  });
